//
//  MeHeaderV.m
//  YangWifi
//
//  Created by zuoxueliangduyuanzhuo on 2017/6/14.
//  Copyright © 2017年 zuoxueliangduyuanzhuo. All rights reserved.
//

#import "MeHeaderV.h"

@interface MeHeaderV ()

@property (nonatomic ,weak) IBOutlet UILabel *telL;

@property (nonatomic ,weak) IBOutlet UILabel *nickL;

@property (nonatomic ,weak) IBOutlet UILabel *loginL;

@property (nonatomic ,weak) IBOutlet UIImageView *headV;


@end
@implementation MeHeaderV

- (void)buildData
{
    if ([AccountHanler isLogin]) {
        self.telL.hidden = NO;
        self.nickL.hidden = NO;
        self.loginL.hidden = YES;
        self.telL.text = [AccountHanler telPhone];
        self.nickL.text = [[AccountHanler nickName] length] > 0?[AccountHanler nickName]:[AccountHanler username];
    }else{
        self.telL.hidden = YES;
        self.nickL.hidden = YES;
        self.loginL.hidden = NO;
    }
}

-(id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if(self)
    {
        //you init
    }
    return self;
}

+(MeHeaderV *)instanceMeHeaderView
{
    NSArray* nibView =  [[NSBundle mainBundle] loadNibNamed:@"MeHeaderV" owner:nil options:nil];
    return [nibView objectAtIndex:0];
}


- (void)tapClick:(UITapGestureRecognizer *)tap
{
    if (self.headerHandler) {
        self.headerHandler();
    }
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick:)];
    
    [self addGestureRecognizer:tap];
//    [self.nickL addGestureRecognizer:tap];
//    [self.loginL addGestureRecognizer:tap];
//    [self.telL addGestureRecognizer:tap];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
